package cn.itcast.web.controller.system;

import cn.itcast.domain.system.SysLog;
import cn.itcast.service.system.SysLogService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/system/log")
public class SysLogController extends BaseController {
  @Autowired
  private SysLogService sysLogService;

  /*
  方法的作用：展示日志列表
  url: /system/log/list.do
  参数： 当前页， 页面大小
  返回： system/log/log-list
   */
  @RequestMapping("/list")
  public String list(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "5") int pageSize) {
    //1. 查询到pageInfo对象
    //companyId是指当前登陆者所属的公司id.
    PageInfo<SysLog> pageInfo = sysLogService.findByPage(pageNum, pageSize, getLoginCompanyId());
    //2. 把PageInfo存储到域中
    request.setAttribute("pageInfo",pageInfo);
    //3. 返回到列表页面
    return "system/log/log-list";
  }
}
